package com.thermofisher.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

@Component
public class ReadDataRemote
{
    @Autowired
    private RestTemplate restTemplate;

    public void getAccessToken()
    {
        String url = "https://test.salesforce.com";
        //HttpHeaders headers = new HttpHeaders();
        //headers.setContentType(MediaType.APPLICATION_JSON);
        // 封装参数，千万不要替换为Map与HashMap，否则参数无法传递
        MultiValueMap<String, String> paramMap = new LinkedMultiValueMap<>();
        paramMap.add("paramMap", "3MVG9e2mBbZnmM6ks2kVSUB0EdmEdBA..x4Yuv" +
                ".HH1VGyrConw5t1ZLuUUia76C1bVBK2nX0C89A5WVqIE33i");
        paramMap.add("client_secret",
                     "380EBEDAECF3D8E9CAF32322BFD127575DF300FECD889907EEB32738DBC4173E");
        paramMap.add("username", "integration@thermofisher.com.b1000");
        paramMap.add("password", "Integr@ti0n8xvAyLGrZTBBbxani3DcyOf2O");
        paramMap.add("grant_type", "password");
        ResponseEntity<Object> entity = restTemplate.postForEntity(url, paramMap, Object.class);
        //获取3方接口返回的数据通过entity.getBody();它返回的是一个字符串；
        Object body = entity.getBody();

    }

}
